package vn.fpt.fsoft.entities;



import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
@Entity
@Table(name="Town")
public class Town implements java.io.Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = -2837489117591791068L;
	private int townId;
	private County county;
	private Nation nation;
	private String townName;
	private Set<Address> addresses = new HashSet<Address>(0);

	public Town() {
	}

	/**
	 * @param townId
	 * @param county
	 * @param nation
	 * @param townName
	 * @param addresses
	 */
	public Town(int townId, County county, Nation nation, String townName,
			Set<Address> addresses) {
		super();
		this.townId = townId;
		this.county = county;
		this.setNation(nation);
		this.townName = townName;
		this.addresses = addresses;
	}

	@Id
	@GeneratedValue
	@Column(name = "TownId", unique = true, nullable = false)
	public int getTownId() {
		return this.townId;
	}

	public void setTownId(int townId) {
		this.townId = townId;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "CountyId")
	public County getCounty() {
		return this.county;
	}

	public void setCounty(County county) {
		this.county = county;
	}

	/**
	 * @return the nation
	 */
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "NationId")
	public Nation getNation() {
		return nation;
	}

	/**
	 * @param nation
	 *            the nation to set
	 */
	public void setNation(Nation nation) {
		this.nation = nation;
	}

	@Column(name = "TownName")
	public String getTownName() {
		return this.townName;
	}

	public void setTownName(String townName) {
		this.townName = townName;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "town")
	public Set<Address> getAddresses() {
		return this.addresses;
	}

	public void setAddresses(Set<Address> addresses) {
		this.addresses = addresses;
	}

}
